home *** CD-ROM | disk | FTP | other *** search
- #include <IV-look/kit.h>
- #include <InterViews/background.h>
- #include <InterViews/box.h>
- #include <InterViews/deck.h>
- #include <InterViews/label.h>
- #include <InterViews/glue.h>
- #include <InterViews/patch.h>
- #include <InterViews/place.h>
- #include <InterViews/session.h>
- #include <InterViews/style.h>
- #include <InterViews/window.h>
-
- class App {
- public:
- Glyph* make(Style*);
- void next();
- void prev();
- private:
- Deck* deck_;
- Patch* patch_;
-
- void flip(GlyphIndex);
- };
-
- declare(ActionCallback,App)
- implement(ActionCallback,App)
-
- Glyph* App::make(Style* s) {
- const Font* f = s->font();
- const Color* fg = s->foreground();
- deck_ = new Deck;
- deck_->append(new Label("Hi mom!", f, fg));
- deck_->append(new Label("Big Bird", f, fg));
- deck_->append(new Label("Oscar", f, fg));
- deck_->flip_to(0);
- patch_ = new Patch(deck_);
- return patch_;
- }
-
- void App::next() {
- GlyphIndex cur = deck_->card() + 1;
- flip(cur == deck_->count() ? 0 : cur);
- }
-
- void App::prev() {
- GlyphIndex cur = deck_->card() - 1;
- flip(cur == -1 ? deck_->count() - 1 : cur);
- }
-
- void App::flip(GlyphIndex cur) {
- deck_->flip_to(cur);
- patch_->redraw();
- patch_->reallocate();
- patch_->redraw();
- }
-
- int main(int argc, char** argv) {
- Session* session = new Session("Himom", argc, argv);
- Style* style = session->style();
- Kit* kit = Kit::instance();
- App* a = new App;
- session->run_window(
- new ApplicationWindow(
- new Background(
- new Margin(
- new TBBox(
- new VCenter(a->make(style), 1.0),
- new VGlue(5.0),
- new LRBox(
- kit->simple_push_button(
- "Next", style,
- new ActionCallback(App)(a, &App::next)
- ),
- new HGlue(10.0),
- kit->simple_push_button(
- "Previous", style,
- new ActionCallback(App)(a, &App::prev)
- )
- )
- ),
- 10.0
- ),
- style->flat()
- )
- )
- );
- }
-